package com.bootdo.clouddoES.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * rabbitmq生产者示例
 *
 * @Author YUBIN
 */
@Component // 将该类交给Spring管理
public class InterfaceProducerDemo {

    private static Logger logger = LoggerFactory.getLogger(InterfaceProducerDemo.class);

    @Autowired // 注入rabbitmq 模板
    private AmqpTemplate rabbitTemplate;

    /**
     * 发送消息的方法 hello-queue
     */
    public void sendInterfaceMessage() {
        // 定义消息体
        String message = "RabbitMqProducerDemo hello queue send message";
        rabbitTemplate.convertAndSend("interfaceQueue",message);
        logger.info("==================RabbitMqProducerDemo hello queue send message success");
    }

}